//
// Created by 33145 on 2023/6/9.
//

#ifndef ROCKET_RPC_CLOSURE_H
#define ROCKET_RPC_CLOSURE_H

#include <google/protobuf/stubs/callback.h>
#include <memory>
#include <functional>

namespace rocket {
class RPCClosure : public google::protobuf::Closure {
public:
  typedef std::shared_ptr<RPCClosure> ptr;
  explicit RPCClosure(std::function<void()> cb) : _cb(cb) {}
  void Run() override {
    if (_cb) {
      _cb();
    }
  }

private:
  std::function<void()> _cb {nullptr};
};


}


#endif //ROCKET_RPC_CLOSURE_H
